

<include file="public@header" />
</head>
<body>
<div class="wrap js-check-wrap">

    <form class="well form-inline margin-top-20" method="get" >

        状态:
        <select class="form-control" name="category" id="status" style="width: 140px;">
            <option value='-1'>全部</option>
            <option value='1'>获取</option>
            <option value='2'>使用</option>

        </select> &nbsp;&nbsp;

        来源:
        <select class="form-control" name="category" id="get" style="width: 140px;">
            <option value='-1'>全部</option>
            <option value='3'>积分兑换</option>
            <option value='2'>用户赠送</option>
            <option value='1'>后台赠送</option>
        </select> &nbsp;&nbsp;

        开始时间:
        <input type="text" class="form-control js-bootstrap-date" id="start_time"
               value="{$start_time|default=''}"
               style="width: 140px;" autocomplete="off">

        结束时间:
        <input type="text" class="form-control js-bootstrap-date" id="end_time"
               value="{$start_time|default=''}"
               style="width: 140px;" autocomplete="off">

        <input type="button" id="selectval" class="btn btn-primary" value="搜索" />

    </form>

    <table class="table table-hover table-bordered">

        <table class="layui-hide" id="test" lay-filter="test"></table>

        <script type="text/html" id="toolbarDemo">
            <div class="layui-btn-container">
<!--                <button class="layui-btn layui-btn-sm " id="allscore"></button>-->
            </div>
        </script>
        <script type="text/html" id="barDemo">
            {{#  if(d.status == 0){ }}
            <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
            {{#  } }}

            {{#  if(d.status != 0){ }}
            <a class="layui-btn layui-btn-xs layui-btn-disabled" >删除</a>
            {{#  } }}

        </script>

        <script type="text/html" id="titleTpl">
            {{#  if(d.status == 0){ }}未使用 {{#  } }}
            {{#  if(d.status == 1){ }} 已使用{{#  } }}
            {{#  if(d.status == 2){ }} 已赠送{{#  } }}
            {{#  if(d.status == 3){ }} 已过期{{#  } }}
        </script>
        <script type="text/html" id="titleTpl2">
            {{#  if(d.status == 1){ }}
            <span > {{d.count}} </span>
            {{#  } }}
            {{#  if(d.status == 2){ }}
            <span style="color: red"> -{{d.count}} </span>
            {{#  } }}

        </script>

        <script>

            var id="{$id}";

            layui.use('table', function(){
                var table = layui.table;


                var tableIns =table.render({
                    elem: '#test' ,
                    url:'seelogs',
                    method: 'post',
                    toolbar: '#toolbarDemo',
                    title: '用户数据表',
                    where: {id:id},
                    totalRow: true ,
                    cols: [[
                        {field:'id', title:'ID', width:80, fixed: 'left', totalRowText: '合计'}
                        ,{field:'user_nickname', title:'用户',edit: 'text'}
                        ,{field:'name', title:'名称',edit: 'text'}
                        ,{field:'count', title:'数量', templet: '#titleTpl2'}
                        ,{field:'fuser', title:'关联人'}
                        ,{field:'desc', title:'备注'}
                        ,{field:'gettime', title:'获得时间'}
                        // ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
                    ]]
                    ,page: true,

                });


                $("#selectval").click(function (){

                    var status=$("#status").val();
                    var get=$("#get").val();
                    var start_time=$("#start_time").val();
                    var end_time=$("#end_time").val();

                    tableIns.reload({
                        where: { status: status,gets:get,start_time:start_time,end_time:end_time,id:id} ,
                        page: { curr: 1  }
                    });

                })

                //表格工具行事件
                table.on('tool(test)', function(obj){
                    var data = obj.data;
                    //console.log(obj)
                    if(obj.event === 'del'){
                        layer.confirm('真的删除么', function(index){

                            $.ajax({
                                url:'delete',
                                data:{'id':data.id},
                                type:'post',
                                success:function (ret){

                                    layer.msg(ret.msg)
                                    obj.del();
                                    layer.close(index);
                                }
                            })




                        });
                    }
                });




            });
        </script>


    </table>

</div>
<script src="__STATIC__/js/admin.js"></script>
</body>
</html>